<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
	<title>继承练习</title>
</head>
<body>
<?php 

/**
继承允许建立一个新的派生类，从一个先前定义的类中继承数据和函数，而且可以重新定义或加进来新的数据和函数；子类对父类功能的拓展；子类可以重载父类的方法，在php中只可以单继承，继承中关键字extends
*/
class Person 
{

	protected $name;
	protected $age;
	protected $sex;
	function __construct($name,$age,$sex){
    $this->name=$name;
     $this->age=$age;
      $this->sex=$sex;

	}
	
	function say(){
		echo "我的姓名是".$this->name;
		echo "我的年龄是".$this->age;
		echo "我的性别是".$this->sex."<br>";

	}


}




	class Student extends Person {
		var $school;
		function study(){
			echo $this->name."正在".$this->school."学习"."<br>";
		}
	}


	class Teacher extends Student{
		var $wage;
		function teach(){
			echo $this->name."正在".$this->school."教学"."工资是".$this->wage."<br>";
		}
	}


	$t1=new Teacher("zhangsan","80","man");
    $t1->school="neusoft";
    $t1->wage="6000";
    $t1->say();
    $t1->study();
    $t1->teach();
	

 ?>

</body>
</html>

